package com.luck.org.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

import com.luck.pf.util.DateUtil;
import com.luck.pf.util.FormateUtil;


/**
 * @hibernate.class table="SYS_USER"
 * 说明:人员表
 * Copyright: Copyright (c) 2010
 * @author zhangwenrui 2010-8-4 下午02:52:41
 * @version 1.0
 */
public class SysUser  implements Serializable {
	private static final long serialVersionUID = 57626928745523430L;
	private Long id;
	private Long deptId;
	private SysDepartment dept;
    private String loginname; // 登录名
    private String realname;//真实名字
    private String password; // 密码
    private String psw;//明文
    private String sex;//性别
    private String officePhone; // 办公电话
    private String mobilePhone; // 移动电话
    private String email; // 电子邮件
    private String fax; // 传真
    private String address;
    private int enabled; // 是否可用
    private String userLevel;//用户级别,1:管理员,2:操作员
    private Long createdUser;//创建人
    private Date createdDate; //创建日期
	private Long operUser;//操作人
	private Date operTime;//操作时间    
	private Date lastLoginDate; //最后登录时间
    private String remark; // 备注
    private String systemFlag;//系统标设，ROOT:全部功能, ROOT_ORG:后台管理，ROOT_BS:前台系统 
    private Set roles;
	/**
	 * 业务资源权限列表
	 */
    private List resources;
	/**
	 * 判断某一资源是否在资源列表中
	 * @param id
	 * @return
	 */
	public boolean findResource(String id){
		if(resources == null || resources.isEmpty())
			return false;
		if(resources.contains(id))
			return true;
		return false;
	}

	/**
     * @hibernate.id generator-class = "sequence" 
     * @hibernate.generator-param name="sequence" value="seq_sys_user"
     * @hibernate.column sql-type="NUMBER(22,0)" name="id"
     * @return
     */
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}

	/**
     * @hibernate.property length="16" column="dept_id"
     */
	public Long getDeptId() {
		return deptId;
	}

	public void setDeptId(Long deptId) {
		this.deptId = deptId;
	}

    /**
     * @hibernate.many-to-one class = "com.luck.org.entity.SysDepartment" column="dept_id" insert="false" update="false"
     * @return
     */
	public SysDepartment getDept() {
		return dept;
	}

	public void setDept(SysDepartment dept) {
		this.dept = dept;
	}

	/**
     * @hibernate.property length="30" column="loginname"
     */
	public String getLoginname() {
		return loginname;
	}

	public void setLoginname(String loginname) {
		this.loginname = loginname;
	}

	/**
     * @hibernate.property length="20" column="realname"
     */
	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	/**
     * @hibernate.property length="50" column="password"
     */
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	/**
     * @hibernate.property length="50" column="psw"
     */
	public String getPsw() {
		return psw;
	}

	public void setPsw(String psw) {
		this.psw = psw;
	}

	/**
     * @hibernate.property length="10" column="sex"
     */
	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	/**
     * @hibernate.property length="30" column="officePhone"
     */
	public String getOfficePhone() {
		return officePhone;
	}

	public void setOfficePhone(String officePhone) {
		this.officePhone = officePhone;
	}

	/**
     * @hibernate.property length="30" column="mobilePhone"
     */
	public String getMobilePhone() {
		return mobilePhone;
	}

	public void setMobilePhone(String mobilePhone) {
		this.mobilePhone = mobilePhone;
	}

	/**
     * @hibernate.property length="30" column="email"
     */
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	/**
     * @hibernate.property length="30" column="fax"
     */
	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	/**
     * @hibernate.property length="100" column="address"
     */
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	/**
     * @hibernate.property length="2" column="is_enabled"
     */
	public int getEnabled() {
		return enabled;
	}

	public void setEnabled(int enabled) {
		this.enabled = enabled;
	}

	/**
     * @hibernate.property length="2" column="user_level"
     */
	public String getUserLevel() {
		return userLevel;
	}

	public void setUserLevel(String userLevel) {
		this.userLevel = userLevel;
	}

	/**
     * @hibernate.property length="30" column="created_user"
     */
	public Long getCreatedUser() {
		return createdUser;
	}

	public void setCreatedUser(Long createdUser) {
		this.createdUser = createdUser;
	}

	/**
     * @hibernate.property column="created_date"
     */
	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	/**
     * @hibernate.property length="16" column="oper_user"
     */
	public Long getOperUser() {
		return operUser;
	}
	public void setOperUser(Long operUser) {
		this.operUser = operUser;
	}
	/**
     * @hibernate.property column="oper_time"
     */
	public Date getOperTime() {
		return operTime;
	}
	public void setOperTime(Date operTime) {
		this.operTime = operTime;
	}

	/**
     * @hibernate.property column="last_login_date"
     */
	public Date getLastLoginDate() {
		return lastLoginDate;
	}

	public void setLastLoginDate(Date lastLoginDate) {
		this.lastLoginDate = lastLoginDate;
	}

	/**
     * @hibernate.property length="500" column="remark"
     */
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public List getResources() {
		return resources;
	}

	public void setResources(List resources) {
		this.resources = resources;
	}

	/**
     * @hibernate.set name="person" table="sys_user_role" cascade="none" inverse="false"
     * @hibernate.collection-key column="user_id" 
     * @hibernate.collection-many-to-many class="com.luck.org.entity.SysRole" column="role_id"
     */
	public Set getRoles() {
		return roles;
	}

	public void setRoles(Set roles) {
		this.roles = roles;
	}

	/**
     * @hibernate.property length="10" column="system_flag"
     */
	public String getSystemFlag() {
		return systemFlag;
	}

	public void setSystemFlag(String systemFlag) {
		this.systemFlag = systemFlag;
	}

	public String getEnabledStr() {
		if(this.enabled==1)
			return "启用";
		else
			return "停用";
	}

	public String getUserLevelStr() {
		String str = "";
		if(this.userLevel.equals("1"))
			str="管理员";
		if(this.userLevel.equals("2"))
			str="操作员";
		return str;
	}

	public String getSystemFlagStr() {
		return FormateUtil.getInstance().getNameByCode("p_system_flag", this.systemFlag);
	}

	public String getLastLoginDateStr() {
		if(this.lastLoginDate == null)
			return "";
		return DateUtil.dateToString(this.lastLoginDate,DateUtil.patternE);
	}

}
